﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Enter.DataProxy.DbConnector.Helpers;
using Enter.DataCommon;

namespace Enter.DataProxy.DbConnector.EntLib
{
    /// <summary>
    /// 数据写入器(依赖企业库的实现)
    /// </summary>
    public class DatabaseWriter : DbWriter
    {
        private DbHelper _DbHelper;

        /// <summary>
        /// 初始化数据读取器
        /// </summary>
        /// <param name="name">配置文件中数据链接字符串的组名称，依赖企业库的配置文件。</param>
        public DatabaseWriter(string name)
        {
            _DbHelper = new DatabaseHelper(name);
        }

        //public override SqlBuilder SqlBuilder
        //{
        //    get { return _DbHelper.SqlBuilder; }
        //}

        public override ParameterCollection CreateParamCollection()
        {
            return _DbHelper.CreateParamCollection();
        }

        public override ParameterCollection CreateParamCollection(int capacity)
        {
            return _DbHelper.CreateParamCollection(capacity);
        }

        protected internal override DataSet ExecuteDataSet(CommandType cmdType, string cmdText, ParameterCollection parameters)
        {
            return _DbHelper.ExecuteDataSet(cmdType, cmdText, parameters);
        }

        protected internal override int ExecuteNonQuery(CommandType cmdType, string cmdText, ParameterCollection parameters, bool mustTransaction)
        {
            return _DbHelper.ExecuteNonQuery(cmdType, cmdText, parameters, mustTransaction);
        }

        protected internal override IDataReader ExecuteReader(CommandType cmdType, string cmdText, ParameterCollection parameters)
        {
            return _DbHelper.ExecuteReader(cmdType, cmdText, parameters);
        }

        protected internal override object ExecuteScalar(CommandType cmdType, string cmdText, ParameterCollection parameters, bool mustTransaction)
        {
            return _DbHelper.ExecuteScalar(cmdType, cmdText, parameters, mustTransaction);
        }

    }
}
